% draws the body of the dog, once every freq steps.
% the figure's resolution and size is fixed.

function seeDog(pathfilename, outfilename, freq)
   gridSize = 0.01;
   xMin = -.20;
   xMax = 3;
   yMin = -1.5;
   yMax = 1.5;
   numXvalues = floor((xMax-xMin)/gridSize);
   numYvalues = floor((yMax-yMin)/gridSize);

   image = zeros(numXvalues, numYvalues);
   actions = load(pathfilename);
   
   numSteps = length(actions(:,1));
   x = zeros(1,4);
   y = zeros(1,4);
   foundfoot = zeros(1,4);
   figure; 
   hold on;
   axis([yMin yMax xMin xMax]);
   for i=1:freq:numSteps
      foundfoot = zeros(1,4);
      for j=1:4
         counter = i;
         while foundfoot(j) == 0
            if counter<=length(actions(:,1))
               x(actions(counter,1)+1) = actions(counter,3);
               y(actions(counter,1)+1) = actions(counter,2);
               foundfoot(actions(counter,1)+1) = 1;
               counter = counter + 1;
            else
                foundfoot(j)=1;
            end
         end
      end
      fill([x(1), x(2), x(4), x(3)],[y(1), y(2), y(4), y(3)],'r');
   end
   
   %imwrite(image, outfilename,'tif');

end